<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>document</title>
    <style>
    </style>
</head>
<body>
<h1>第一条</h1>
<h2>第二条</h2>
<h3>第三条</h3>
<h4>第四条</h4>
<script>

    var currentPort
    window.addEventListener("message",(event)=>{
        if(event.data==="trans_port"){
        //说明传递过来了接口
        currentPort  =  event.ports[0]
        if(currentPort){
       // alert("接受电话成功")
       currentPort.onmessage = (params) =>{
       alert(JSON.parse(params.data).value)
       }
        }
       }

    })
</script>
</body>
</html>